local tiaoxin = fk.CreateSkill {

  name = "joy__tiaoxin",

  tags = {  },

}



tiaoxin:addEffect(fk.EventPhaseStart, {
  name = "joy__tiaoxin",
  events = {fk.EventPhaseStart},
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(tiaoxin.name) and player.phase == Player.Play
  end,
  on_cost = function (self,event,target,player,data)
    local targets = {}
    for _, p in ipairs(player.room:getOtherPlayers(player)) do
      if not p:isKongcheng() then
        table.insert(targets,p.id)
      end
    end
    local to = player.room:askForChoosePlayers(player,targets,1,1,"#joy__tiaoxin-ask",tiaoxin.name,true)
    if #to > 0 then
      event:setCostData(self, to[1])
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(event:getCostData(self))
    local cards = player.room:askForCardsChosen(player, to,1,2, "h", tiaoxin.name,"joy__tiaoxin-throw")
    local n = false
    for _, ids in ipairs(cards) do
      local card = Fk:getCardById(ids)
      if card.trueName == "slash" then
        n = true
      end
    end
    room:throwCard(cards,tiaoxin.name,to,player)
    if n and not player:isNude() and not player.dead then
      room:askForDiscard(player,1,1,true,tiaoxin.name,false)
    end
  end
})

return tiaoxin